﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Extensil.Processor;

namespace Extensil
{
    public partial class ProgressUpdate :Form
    {
        TaskReader tr = new TaskReader();
        public ProgressUpdate()
            : this(String.Empty)
        {
        }
        public ProgressUpdate(string format)
        {
            InitializeComponent();
            pbTask.Maximum = 100;
            pbTask.Minimum = 0;
            pbMain.Maximum = 100;
            pbMain.Minimum = 0;
            tr = new TaskReader(format);
        }
        public void Add(TaskStatus ts, int progressPercentage)
        {
            if(ts.Source == StatusSource.Main)
            {
                pbMain.Value = progressPercentage;
                lblTaskName.Text = ts.Message;
            }
            else
            {
                pbTask.Value = ts.PercentProgress;
                lbStatus.Items.Add(tr.FormatLog(ts.Message));
                lbStatus.TopIndex = lbStatus.Items.Count - 1;
            }
        }
    }
}
